package cn.ruicz.basecore.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

import cn.ruicz.basecore.bean.ItemPager;


/**
 * Created bt liqq on 2019/2/26
 */
public class ViewPagerAdapter extends FragmentPagerAdapter {

    private List<ItemPager> mFragmentList;

    public ViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setFragmentList(List<ItemPager> fragmentList){
        this.mFragmentList = fragmentList;
    }

    public List<ItemPager> getFragmentList(){
        return mFragmentList;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position).itemFragment;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mFragmentList.get(position).title;
    }

    @Override
    public int getCount() {
        return mFragmentList == null ? 0 : mFragmentList.size();
    }
}
